import { userAccountLogin } from '@/api/user.js'
// 用户状态
export default {
  namespaced: true,
  state: () => ({
    // 个人用户信息
    profile: {
      id: '',
      nickname: '',
      avatar: '',
      token: '',
      mobile: ''
    }
  }),
  mutations: {
    setUser (state, useInfo) {
      state.profile = useInfo
    },
    clearUser (state) {
      state.profile = {}
    }
  },
  actions: {
    async setLoginUser (ctx, { account, password }) {
      const res = await userAccountLogin({ account, password })
      ctx.commit('setUser', res.data.result)
    }
  },
  getters: { }
}
